﻿using System;
using System.Windows.Forms;
using BusinessCommon.Utilities;

namespace CustomControlLibrary
{
    public partial class StmConfirmDialog : Form
    {
        /// <summary>
        /// Result
        /// </summary>
        private bool result = false;

        /// <summary>
        /// Confirm dialog
        /// </summary>
        public StmConfirmDialog()
        {
            InitializeComponent();
            SetLanguage();
            InitForm();
        }

        /// <summary>
        /// Show confirm dialog
        /// </summary>
        /// <param name="question">Question</param>
        /// <returns>true: OK; false: Cancel</returns>
        public bool ShowDialog(string question)
        {
            if (!String.IsNullOrEmpty(question))
            {
                txtText.Text = question;
            }
            base.ShowDialog();
            return result;
        }

        /// <summary>
        /// Set multilang
        /// </summary>
        private void SetLanguage()
        {
            btnOK.setMultiLanguage(this.Name, btnOK.Name);
            btnCancel.setMultiLanguage(this.Name, btnCancel.Name);
            this.Text = ResxManagerString.GetPropertyString(this.Name, this.Name);
        }

        /// <summary>
        /// Init form
        /// </summary>
        private void InitForm()
        {
        }

        /// <summary>
        /// Handle button OK click action
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            result = true;
            this.Close();
        }

        /// <summary>
        /// Handle button Cancel click action
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            result = false;
            this.Close();
        }
    }
}
